package com.fyp.erp;

import java.util.Arrays;
import com.androidplot.series.XYSeries;
import com.androidplot.xy.LineAndPointFormatter;
import com.androidplot.xy.SimpleXYSeries;
import com.androidplot.xy.XYPlot;
import android.app.TabActivity;
import android.os.Bundle;
import android.view.Window;
import android.widget.Button;
import android.widget.TabHost;
import android.content.Intent;
import android.graphics.Color;
import android.view.View;


public class SCMPlanning extends TabActivity {

	private TabHost tabHost;
	private XYPlot mySimpleXYPlot;


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.scmplanning);

		String tabname1 = "Product Plan";
		String tabname2 = "Manufacturing Resource Plan";
		String tabname3 = "Material Requirement Plan";
		String tabname4 = "Project Management";

		tabHost = getTabHost();
		tabHost.addTab(tabHost.newTabSpec("tab1").setContent(R.id.layout_tab_one).setIndicator(tabname1));
		tabHost.addTab(tabHost.newTabSpec("tab2").setContent(R.id.layout_tab_two).setIndicator(tabname2));
		tabHost.addTab(tabHost.newTabSpec("tab3").setContent(R.id.layout_tab_three).setIndicator(tabname3));
		tabHost.addTab(tabHost.newTabSpec("tab4").setContent(R.id.layout_tab_four).setIndicator(tabname4));

		tabHost.setCurrentTab(0);

		getProdPlanGraph();
		getMatReqPlanGraph();

		Button btn1 = (Button) findViewById(R.id.button1);
		btn1.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				Intent i = new Intent("com.fyp.erp.ProductDemand");
				startActivity(i);
			}

		});

		Button btn2 = (Button) findViewById(R.id.button2);
		btn2.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				Intent i = new Intent("com.fyp.erp.ProductDesign");
				startActivity(i);
			}

		});

		Button btn3 = (Button) findViewById(R.id.button3);
		btn3.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				Intent i = new Intent("com.fyp.erp.MaterialCost");
				startActivity(i);
			}

		});

		Button btn4 = (Button) findViewById(R.id.button4);
		btn4.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				Intent i = new Intent("com.fyp.erp.SupplierDetail");
				startActivity(i);
			}

		});

	}

	private void getMatReqPlanGraph() {
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// Initialize our XYPlot reference:
		mySimpleXYPlot = (XYPlot) findViewById(R.id.matReqPlanGraph);

		// Create two arrays of y-values to plot:
		Number[] series1Numbers = {2, 8, 5, 2, 7, 4};
		Number[] series2Numbers = {5, 4, 7, 8, 4, 5};

		// Turn the above arrays into XYSeries:
		XYSeries series1 = new SimpleXYSeries(
				Arrays.asList(series1Numbers),          // SimpleXYSeries takes a List so turn our array into a List
				SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, // Y_VALS_ONLY means use the element index as the x value
				"Series1");                             // Set the display title of the series

		// Same as above, for series2
		XYSeries series2 = new SimpleXYSeries(Arrays.asList(series2Numbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, 
				"Series2");

		// Create a formatter to use for drawing a series using LineAndPointRenderer:
		LineAndPointFormatter series1Format = new LineAndPointFormatter(
				Color.rgb(0, 200, 0),                   // line color
				Color.rgb(0, 100, 0),                   // point color
				Color.rgb(150, 190, 150));              // fill color (optional)

		// Add series1 to the xyplot:
		mySimpleXYPlot.addSeries(series1, series1Format);

		// Same as above, with series2:
		mySimpleXYPlot.addSeries(series2, new LineAndPointFormatter(Color.rgb(0, 0, 200), Color.rgb(0, 0, 100),
				Color.rgb(150, 150, 190)));


		// Reduce the number of range labels
		mySimpleXYPlot.setTicksPerRangeLabel(3);

		// By default, AndroidPlot displays developer guides to aid in laying out your plot.
		// To get rid of them call disableAllMarkup():
		mySimpleXYPlot.disableAllMarkup();

	}

	private void getProdPlanGraph() {
		// TODO Auto-generated method stub
		// Initialize our XYPlot reference:
		mySimpleXYPlot = (XYPlot) findViewById(R.id.prodPlanGraph);

		// Create two arrays of y-values to plot:
		Number[] series1Numbers = {2, 8, 5, 2, 7, 4};
		Number[] series2Numbers = {5, 4, 7, 8, 4, 5};

		// Turn the above arrays into XYSeries:
		XYSeries series1 = new SimpleXYSeries(
				Arrays.asList(series1Numbers),          // SimpleXYSeries takes a List so turn our array into a List
				SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, // Y_VALS_ONLY means use the element index as the x value
				"Series1");                             // Set the display title of the series

		// Same as above, for series2
		XYSeries series2 = new SimpleXYSeries(Arrays.asList(series2Numbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, 
				"Series2");

		// Create a formatter to use for drawing a series using LineAndPointRenderer:
		LineAndPointFormatter series1Format = new LineAndPointFormatter(
				Color.rgb(0, 200, 0),                   // line color
				Color.rgb(0, 100, 0),                   // point color
				Color.rgb(150, 190, 150));              // fill color (optional)

		// Add series1 to the xyplot:
		mySimpleXYPlot.addSeries(series1, series1Format);

		// Same as above, with series2:
		mySimpleXYPlot.addSeries(series2, new LineAndPointFormatter(Color.rgb(0, 0, 200), Color.rgb(0, 0, 100),
				Color.rgb(150, 150, 190)));


		// Reduce the number of range labels
		mySimpleXYPlot.setTicksPerRangeLabel(3);

		// By default, AndroidPlot displays developer guides to aid in laying out your plot.
		// To get rid of them call disableAllMarkup():
		mySimpleXYPlot.disableAllMarkup();
	}
}










